package com.smartwebee.android.blespp.blockly;

public class BlockTestCommand {

    //开灯命令
    public static final String OPEN_LIGHT = "mymodule.set_led(0x07, 0x02)";
    //关灯命令
    public static final String OFF_LIGHT = "mymodule.set_led(0x07, 0x00)";
    /**
     * 获取电机旋转的命令
     * @param speed 旋转速度
     * @return 命令字符串
     */
    public static String getSpinStr(String speed) {
        return "mymodule.set_pwm(" + speed + ")";
    }

    /**
     * 获取led命令字符串
     *
     * @param index 控制的led编号 0左灯 1右灯 3全部灯
     * @param red red色值 0-255
     * @param green green色值 0-255
     * @param blue blue色值 0-255
     * @return 目标字符串
     */
    public static String getLedStr(String index, String red, String green, String blue) {
        return "setLed("
                + index +  ", "
                + red + ", "
                + green + ", "
                + blue + ")";
    }

    /**
     * 获取蜂鸣器命令字符串
     *
     * @param freq 频率 C2-C5，即65-523
     * @param rhythm 节拍 0.125-2
     * @return 目标字符串
     */
    public static String getBeepStr(String freq, String rhythm) {
        return "setBeep("
                + freq + ", "
                + rhythm + ")";
    }
}
